﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EHTWebsite.Code;

namespace EHTWebsiteProject
{
    public partial class News : System.Web.UI.Page
    {
        private Int32 pageIndex = 1;
        private Int32 pageSize = 5;
        private Int32 totalRecord = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    pageIndex = Int32.Parse(Request.QueryString["PageIndex"].ToString());
                }
                catch (Exception)
                {
                    pageIndex = 1;
                }
                LoadNews();
            }
        }

        public void LoadNews()
        {
            TinTuc theTinTuc = new TinTuc();
            theTinTuc.TieuDeVN = "";
            theTinTuc.TieuDeOther = "";
            theTinTuc.DanhMucTinTucID = -1;
            pageSize = this.PaggingConTrol.PageSize;
            this.rpTinTuc.DataSource = TinTucProvider.GetTinTucsByFillterT(theTinTuc, pageIndex, pageSize, out totalRecord);
            this.rpTinTuc.DataBind();
            this.PaggingConTrol.TotalRecord = totalRecord;
            this.PaggingConTrol.PageURL = "nyheter.html";
        }
    }
}